'use strict';

const Controller = require('egg').Controller;

class BookController extends Controller {
  async banner() {
    this.ctx.body = [
      {
        id: '00000001',
        text: '赢的人生的六种能力',
        image: 'https://img14.360buyimg.com/da/jfs/t1/29606/29/3235/68009/5c24a36aE78d77c33/a313c2fc797ccc98.jpg!q95.webp'
      },
      {
        id: '00000002',
        text: '实话实说-崔永元',
        image: 'https://img13.360buyimg.com/da/jfs/t1/17270/2/3824/58670/5c2c13caE230ce6ca/4a830d1e4649704e.jpg!q95.webp'
      },
      {
        id: '00000003',
        text: '我们都是宇宙中的微尘',
        image: 'http://img56.ddimg.cn/9002790053016276.jpg'
      },
      {
        id: '00000004',
        text: '所有的遇见终将连接奇丽的一生',
        image: 'http://img56.ddimg.cn/9002820077193186.jpg'
      },
      {
        id: '00000005',
        text: '万人如海一身藏',
        image: 'https://img.alicdn.com/imgextra/i2/859515618/O1CN01XwgZpd1rN5aA75caQ_!!859515618.jpg'
      },
    ];
  }

  async detail() {
      const { low, high } = this.ctx.query;
      let data = [
        {
          id: '00000001',
          price: '35.70',
          description: '胜任未来：赢得人生的六种能力',
          comment: '4300+',
          isCollected: false,
          image: '//img13.360buyimg.com/n1/jfs/t1/5835/37/2741/259530/5b976348Ef90852b8/d33c1f3dd9d96ea9.jpg'
        },
        {
          id: '00000002',
          price: '33.80',
          description: '有话说',
          comment: '2000+',
          isCollected: false,
          image: '//img11.360buyimg.com/n1/jfs/t1/29642/37/2927/107855/5c21ec6aE4ef9fc7b/b6fec2416b1aa529.jpg'
        },
        {
          id: '00000003',
          price: '29.20',
          description: '我们都是宇宙中的微尘',
          comment: '886+',
          isCollected: false,
          image: 'http://img3m0.ddimg.cn/35/34/25582130-1_w_4.jpg'
        },
        {
          id: '00000004',
          price: '37.35',
          description: '遇见你之前',
          comment: '108+',
          isCollected: false,
          image: 'http://img3m6.ddimg.cn/93/34/26436756-1_w_3.jpg'
        },
        {
          id: '00000005',
          price: '33.10',
          description: '万人如海一身藏 独木舟新书',
          comment: '200+',
          isCollected: false,
          image: '//img11.360buyimg.com/n1/jfs/t1/9877/39/8774/126801/5c0f64b8Ea67938b7/9de301147ba4d462.png'
        },
        {
          id: '00000006',
          price: '53.00',
          description: '马尔克斯：一起连环绑架案的新闻',
          comment: '220+',
          isCollected: false,
          image: '//img14.360buyimg.com/n1/jfs/t1/18153/20/2422/696270/5c1c8ba0E7032f37d/61f506a449e48cb5.jpg'
        },
        {
          id: '00000007',
          price: '66.00',
          description: '易中天 读唐诗',
          comment: '44万+',
          isCollected: false,
          image: '//img13.360buyimg.com/n1/jfs/t1/16181/19/499/269605/5c0a47b8E15de5023/de35419e4972f5b5.jpg'
        },
        {
          id: '00000007',
          price: '111.80',
          description: '企鹅经典：小黑书 第一辑（共10册）',
          comment: '2000+',
          isCollected: false,
          image: '//img10.360buyimg.com/n1/jfs/t1/8321/14/2551/25991/5bd2cb5fE0d0c6342/3f1d9fd36212f321.jpg'
        }
      ];
      this.ctx.body = data.filter((item) => {
        // console.log(item[type], key)
        return ((!low &&!high) || (Number(item.price) <= high && Number(item.price) >= low));
      })
  }
}

module.exports = BookController;